package com.linkdood.app.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkdood.app.constants.AuthoritiesConstants;
import com.linkdood.app.constants.ErrorCode;
import com.linkdood.app.constants.InternationalCode;
import com.linkdood.app.domain.NoticeMessage;
import com.linkdood.app.domain.Organization;
import com.linkdood.app.domain.User;
import com.linkdood.app.dto.MessageDTO;
import com.linkdood.app.dto.MessageDetailDTO;
import com.linkdood.app.dto.NoticeMessageDTO;
import com.linkdood.app.exception.GeneralException;
import com.linkdood.app.exception.InvalidParamException;
import com.linkdood.app.mapper.NoticeMessageMapper;
import com.linkdood.app.mapper.UserMapper;
import com.linkdood.app.utils.ResourceUtil;
import com.linkdood.app.vm.AccountVM;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 用户消息类
 *
 * @author cfj
 */
public interface NoticeMessageService extends IService<NoticeMessage> {
    /**
     * 获取指定消息的详情
     */
    MessageDetailDTO getMessageDetail(String id);

    /**
     * 查询通知列表
     *
     * @param title     标题
     * @param content   内容
     * @param startTime 开始时间 YYYY-MM-DDTHH:MM:SSZ
     * @param endTime   结束时间 YYYY-MM-DDTHH:MM:SSZ
     * @param pageable  分页
     */
    Page<MessageDetailDTO> pageNotices(String title, String content, LocalDateTime startTime, LocalDateTime endTime, Page<NoticeMessage> pageable);


    /**
     * 创建或者转发消息
     */
    List<MessageDetailDTO> createNotice(NoticeMessageDTO noticeDTO, AccountVM account);


    /**
     * 获取模板消息 url
     */
    String getMessageUrl(String messageId);



    NoticeMessage saveMessage(MessageDTO messageDTO, NoticeMessageDTO noticeMessageDTO);


    List<NoticeMessage> getByThirdIdAndStarTime(String thirdId, String startTime, String endTime);
}
